#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <signal.h>



#define BUFF_LEN 100

#include "key.h"

int fd = 0;
void signal_handler(int signo);
int main(int argc, char *argv[]){
	int flg = 0;
	int ret = 0;
	struct keydata kdat = {0};

	if(argc < 2){
		printf("too few arguments\n");
		return 1;
	}

	fd = open(argv[1], O_RDWR);

	if(fd < 0){
		printf("open failed : %s \n", argv[1]);
		return 2;
	}

	printf("wait key event...\n");
	while((ret = read(fd, &kdat, sizeof(struct keydata)) == sizeof(struct keydata))){
		if(kdat.status == DOWN){
			printf("Key Down\n");
		}else{
			printf("Key Up\n");
		}
	}

	close(fd);
	fd = -1;
	return 0;
}

